<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //打印棱形:两个等腰三角形拼接起来的
		var num = 6;
        var str = "";
        for (var i = 0; i < num; i++) {
            for (var k = 0; k < num - i -1; k++) {
                str += " ";
            }
            for (var j = 0; j < 2*i-1; j++) {
                str += "*";
            }
            str += "\n";
        }
        
        for (var i = 0; i < num; i++) {
            for (var k = 0; k < i+1; k++) {
                str += " ";
            }
            for (var j = 0; j < 2*(num-k)-1; j++) {
                str += "*";
            }
            str += "\n";
        }
        console.log(str);
</script>
</html>